Add ExitStatus overload for on() method in builder classes#5325
Open
tahayigitmelek wants to merge 1 commit intospring-projects:mainfrom
Open
Add ExitStatus overload for on() method in builder classes#5325tahayigitmelek wants to merge 1 commit intospring-projects:mainfrom
tahayigitmelek wants to merge 1 commit intospring-projects:mainfrom
Conversation
Introduce on(ExitStatus) method in builder classes for better type safety Fixes [spring-projects#5306](spring-projects#5306) Add on(ExitStatus) methods as overloaded convenience methods that delegate directly to the existing on(String) methods by extracting the underlying exit code. The new method names make the type-safe behavior explicit and improve API consistency across builder classes. Changes: - `SimpleJobBuilder.on(ExitStatus)` - delegates to on(String) - `FlowBuilder.on(ExitStatus)` - delegates to on(String) - `FlowBuilder.UnterminatedFlowBuilder.on(ExitStatus)` - delegates to on(String) The existing on(String) methods remain for backward compatibility and to preserve wildcard pattern matching. Signed-off-by: Taha Yigit Melek <yigittahamelek@gmail.com> Signed-off-by: tahayigitmelek <yigittahamelek@gmail.com>
023f5d2 to
70f26ee
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5306
Motivation
The current
.on(String pattern)method in builder classes requires developers to use string literals (e.g.,"COMPLETED") to conditionally branch the flow. This approach is prone to typographical errors and does not leverage the predefined, type-safe constants provided by theExitStatusclass.Furthermore, developers intuitively expect to pass an
ExitStatusobject since it represents the actual outcome of a step.Proposed Change
Added
on(ExitStatus status)methods as overloaded convenience methods that delegate directly to the existing.on(String pattern)methods by extracting the underlying exit code.Benefits
Improved Type Safety
Allows using explicitly defined constants like
ExitStatus.COMPLETEDinstead of "magic strings", significantly reducing the risk of typos.Better IDE Support
Enhances developer experience through reliable code completion and static analysis features.
API Consistency
Standardizes flow transition declarations across the builder API, providing a unified and predictable developer experience.
Self-Documenting Code
Makes code more readable by explicitly showing that the transition depends on a predefined exit status.
Changes
SimpleJobBuilder.on(ExitStatus)→ delegates to.on(String)FlowBuilder.on(ExitStatus)→ delegates to.on(String)FlowBuilder.UnterminatedFlowBuilder.on(ExitStatus)→ delegates to.on(String)Backward Compatibility
The existing
.on(String)methods remain for full backward compatibility, ensuring existing wildcard pattern matches (e.g.,"FAIL*","*", or"CUST?M") continue to function perfectly.